package com.mall.controller;

import com.mall.service.ProductService;
import com.mall.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;
    @GetMapping("/listbycid/{categoryId}")
    public ResultVO selectProductByCategoryId(@PathVariable Integer categoryId,Integer pageNum,Integer limit){
       return productService.selectProductByCategoryId(categoryId,pageNum,limit);
    }
    @GetMapping("/listbrands/{categoryId}")
    public ResultVO selectProductBrandByCategoryId(@PathVariable Integer categoryId){

        return productService.selectProductBrandByCategoryId(categoryId);
    }
    @GetMapping("/listbykeyword")
    public ResultVO selectProductByKeyword(String keyword,Integer pageNum,Integer limit){

        return productService.selectProductByKeyword(keyword,pageNum,limit);
    }
    @GetMapping("/listbrands-keyword")
    public ResultVO selectBrandByKeyword(String keyword){

        return productService.selectBrandByKeyword(keyword);
    }
    @GetMapping("detail-info/{productId}")
    public ResultVO selectProductInfoByProductId(@PathVariable String productId){

        return productService.selectProductInfo(productId);
    }
}
